<?php

class IndexController extends Zend_Controller_Action 
{ 
	
	private $_usuario;
	private $_session;
	
    public function preDispatch() {
      /*$plugin = new MyPluginAuth($this->getFrontController()->getParam('auth'), $this->getFrontController()->getParam('acl'));
      Zend_Controller_Front::getInstance ()->registerPlugin($plugin);*/
      if (!Zend_Auth::getInstance()->hasIdentity()) {
      	$this->view->logado = 0;
      	$this->_redirect('login');

      } else {
      	$config = Zend_Registry::get ( 'config' );
      	$this->_session = new Zend_Session_Namespace ( $config->session->namespace );
		$this->_usuario = $this->_session->storage;
		$this->view->perfil = $this->_usuario->perfil;
       	$this->view->logado = 1;
      }
    }
    
  
    public function indexAction() 
    { 
    	$this->view->usuario = $this->_usuario;
    	
    	$grupos = new Grupos();
    	
    	$this->view->grupos = $grupos->fetchAll();
    	
    	/*$session = Zend_Registry::get('session');
    	$usuario = $session->storage;
	   	print $usuario->perfil;*/
	   	
	   	/*$db = Zend_Registry::get('db');
	   	$acl = new MyACL($db);
	   	Zend_Loader::loadClass('MyACL');
	   	$acl->isAllowed($usuario->perfil, 'usuarios') ? print "TEM" : print "NAO TEM";*/
    	
    
        
    }	
}  
